<template>
	<view class="">
		<navbar :title="i18n.xgmm"></navbar>
		<view class="">
			<text class="w690 auto f14 white mt15 block">{{ i18n.ymm }}</text>
			<input type="password" value="" class="w690 h96 bgcc border auto index my15 bor10 f14" :placeholder="i18n.qsrymm" v-model="UsedPws" maxlength="6"/>
		</view>
		<view class="">
			<text class="w690 auto f14 white mt15 block">{{ i18n.mm }}</text>
			<input type="password" value="" class="w690 h96 bgcc border auto index my15 bor10 f14" :placeholder="i18n.qsrxmm" v-model="NewPws" maxlength="6"/>
		</view>
		<view class="">
			<text class="w690 auto f14 white mt15 block">{{ i18n.mm }}</text>
			<input type="password" value="" class="w690 h96 bgcc border auto index my15 bor10 f14" :placeholder="i18n.qzcsrxmm" v-model="NewPwss" maxlength="6"/>
		</view>
		<view class="pt40">
			<view class="btn-blue block auto mt30 w690" @click="Submit()">{{ i18n.tj }}</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			UsedPws:'',
			NewPws:'',
			NewPwss:'',
		};
	},
	computed: {
		i18n() {
			return this.$t('user');
		}
	},
	onLoad() {

	},
	methods: {
		getDeviceInfo(){
			let that = this
			plus.device.getInfo({
				success:function(e){
					that.UID = e.uuid
				},
				fail:function(e){
					that.UID = e.uuid
				}
			});
		},
		async Submit(){
			if(this.UsedPws == ''){
				uni.showToast({
					title:this.$t('tips').ymmtips,
					icon:'none'
				})
				return false
			}
			if(this.NewPws == '' || [...this.NewPws].length != 6 || !/^\d*$/.test(this.NewPws)){
				uni.showToast({
					title:this.$t('tips').mmtips,
					icon:'none'
				})
				return false
			}
			if(this.NewPws != this.NewPwss){
				uni.showToast({
					title:this.$t('tips').mmbyz,
					icon:'none'
				})
				return false
			}
			let params = {
				oldPassword:this.UsedPws,
				newPassword:this.NewPws,
				confirmPassworld:this.NewPwss,
				phoneId:this.UID
			}
			let { data } = await this.$http.post('user.updatePassword', params, { isAuth: true, tipConfig: { isLoading: false } })
			uni.showToast({
				title:this.$t('tips').success,
				icon:'success'
			})
			setTimeout(()=>{
				uni.navigateBack(1)
			},500)
		}
	}
};
</script>

<style lang="less"></style>
